package com.tal.jzb.controller;

import com.tal.jzb.property.CustomPrefixProperty;
import com.tal.jzb.property.CustomProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author xiefengsong
 * @date 2019-01-22 17:49
 */
@RestController
@RequestMapping(value = "/test")
public class TestController {

    @Autowired
    private CustomProperty customProperty;

    @Autowired
    private CustomPrefixProperty customPrefixProperty;

    @GetMapping(value = "/index")
    public Object index() {
        return "hello world!";
    }

    @GetMapping(value = "/getProperty")
    public Object getProperty() {
        return customProperty.toString();
    }

    @GetMapping(value = "/getPrefixProperty")
    public Object getPrefixProperty() {
        return customPrefixProperty.toString();
    }

    @GetMapping(value = "/getCurrentTime")
    public long getCurrentTime(){
        return System.currentTimeMillis();
    }

    @GetMapping(value = "/getCurrentDate")
    public String getCurrentDate(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.format(new Date());
    }
}
